package com.mrjy.maintain.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.util.GlobalConstant;
import com.mrjy.maintain.bo.IUserBindEmailBo;

@RequestMapping("/maintain/userBindEmail")
@Controller
public class UserBindEmailController {

	@Resource
	private IUserBindEmailBo userBindEmailBo;
	
	/**
	 * 验证邮箱绑定链接并绑定邮箱
	 * @param sid
	 * @return
	 */
	@RequestMapping("/bindEmail")
	@ResponseBody
	public String bindEmail(String sid,HttpSession session){
		Map<String , Object> map = userBindEmailBo.txBindEmailExpire(sid);
		String status = (String) map.get("err_code");
		return status;
	}
	
	/**
	 * 验证用户邮箱绑定状态
	 * @param session
	 * @return
	 */
	@RequestMapping("/checkBindEmailState")
	@ResponseBody
	public Object checkBindEmailState(HttpSession session){
		UserInfo userInfo = (UserInfo) session.getAttribute(GlobalConstant.USER_INFO);
		return userBindEmailBo.checkBindEmailState(userInfo);
	}
}
